package easy

import "math"

func ShortestToChar(s string, c byte) []int {
	n := len(s)
	sizeList := make([]int, 0)
	for i := 0; i < n; i++ {
		if s[i] == c {
			sizeList = append(sizeList, i)
		}
	}
	answer := make([]int, n)
	for i := 0; i < n; i++ {
		size := math.MaxInt32
		for j := 0; j < len(sizeList); j++ {
			abs := int(math.Abs(float64(i - sizeList[j])))
			size = min(abs, size)
		}
		answer[i] = size
	}
	return answer
}
